import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import com.magina.common.excel.model.EasyPoiModel;
import org.apache.poi.ss.usermodel.Workbook;
import org.junit.Test;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;

public class EasyPoiTestDemo {


    private static final String preFileName = "/root/magina/excel/";

    //每行数据是List<String>无表头
    @Test
    public void writeWithoutHead() throws IOException {
        OutputStream out = new FileOutputStream(preFileName+"withBean_easypoi_50.xls");
        List<EasyPoiModel> data = new ArrayList<>();
        for (int i = 0; i < 500000; i++) {
            EasyPoiModel item = EasyPoiModel.builder()
                    .name("name" + i)
                    .age("age" + i)
                    .email("email" + i)
                    .address("address" + i)
                    .sax("sax" + i)
                    .loanDate(i+"")
                    .last("last" + i).build();
            data.add(item);
        }
        long start = System.currentTimeMillis();
        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), EasyPoiModel.class, data);
        workbook.write(out);
        System.out.println(String.format("easypoi end writer excel,time:%d",(System.currentTimeMillis()-start)));
        workbook.close();
        out.close();
    }

    List<EasyPoiModel> list;






    }
